//
//  ViewController.m
//  地图coreloationmapkit
//
//  Created by song on 15/9/12.
//  Copyright (c) 2015年 song. All rights reserved.
//

#import "ViewController.h"
#import <CoreLocation/CoreLocation.h>

@interface ViewController ()<CLLocationManagerDelegate>
@property(nonatomic, strong) CLLocationManager *locMgr;
@end

@implementation ViewController


-(CLLocationManager *)locMgr
{
    if(!_locMgr)
    {
        _locMgr = [[CLLocationManager alloc] init];
        _locMgr.delegate = self;
        _locMgr .desiredAccuracy = kCLLocationAccuracyBest;
        _locMgr .distanceFilter = 10;
        [_locMgr  requestAlwaysAuthorization];//添加这句
    }
    return _locMgr;
}


- (void)viewDidLoad {
    [super viewDidLoad];
 
    [self.locMgr startUpdatingLocation];

}


-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
    
    CLLocation *loc = [locations firstObject];
    CLLocationCoordinate2D coordinate  =loc.coordinate;
    NSLog(@"didUpdateLocations -----%f %f",coordinate.latitude ,coordinate.longitude);
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
